"use strict";
import axios from "axios";
class Base {

  static get(url,params,cacheKey) {
    //取缓存值
    if(cacheKey){
      var data = $commmon.cache(cacheKey);
      if(data){
        return Promise.resolve({code: '0', data});
      }
    }
    return axios.get(url,{params}).then(res => {
      if(cacheKey){//设置缓存值
        var data = res.code == '0' ? res.data : null;
        $commmon.cache(cacheKey, data);
      }
      return Promise.resolve(res);
    }).catch(res => {
      return Promise.reject(res);
    });
  }
}

export default Base;
